/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   Module Name          : com.yaodian100.core.form.entity.Attribute
   Module Description   :

   Date Created      : 2009/12/14
   Original Author   : andy.chuang
   Team              : yaodian100
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   MODIFICATION HISTORY
   ------------------------------------------------------------------------------
   Date Modified       Modified by       Comments
   ------------------------------------------------------------------------------
   ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
package com.yaodian100.core.form.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

/**
 * @author andy.chuang
 * 
 */
@Entity
@Table(name = "COMMON_FORM_ATTRIBUTE")
public class Attribute {
	public enum dataTypes {
		Float, Number, Text, Component, Date, TextArea, CheckBox, Radio, RichEditor
	}

	private String id;
	private Form form;
	private String name;
	private String dataType = dataTypes.Text.name();
	private Boolean mandatory = false;
	private Integer maxLength = -1;
	private Integer minLength = -1;
	private Integer maxValue = -1;
	private Integer minValue = -1;
	private String tip;
	private String description;
	private String defaultValue;
	private String presentValues;
	private String dateFormat = "yyyy/MM/dd HH:mm:ss";
	private String presentNames;
	// must be ajax url
	private String componentUrl;
	private Integer sortOrder;

	/**
	 * @return the sortOrder
	 */
	public Integer getSortOrder() {
		return sortOrder;
	}

	/**
	 * @param sortOrder the sortOrder to set
	 */
	public void setSortOrder(Integer sortOrder) {
		this.sortOrder = sortOrder;
	}

	/**
	 * @return the componentUrl
	 */
	@Column(length = 255)
	public String getComponentUrl() {
		return componentUrl;
	}

	/**
	 * @param componentUrl the componentUrl to set
	 */
	public void setComponentUrl(String componentUrl) {
		this.componentUrl = componentUrl;
	}

	/**
	 * @return the presentValues
	 */
	@Column(length = 255)
	public String getPresentValues() {
		return presentValues;
	}

	/**
	 * @param presentValues the presentValues to set
	 */
	public void setPresentValues(String presentValues) {
		this.presentValues = presentValues;
	}

	/**
	 * @return the dateFormat
	 */
	@Column(length = 255)
	public String getDateFormat() {
		return dateFormat;
	}

	/**
	 * @param dateFormat the dateFormat to set
	 */
	public void setDateFormat(String dateFormat) {
		this.dateFormat = dateFormat;
	}

	/**
	 * @return the description
	 */
	@Column(length = 255)
	public String getDescription() {
		return description;
	}

	/**
	 * @param description the description to set
	 */
	public void setDescription(String description) {
		this.description = description;
	}

	/**
	 * @return the tip
	 */
	@Column(length = 255)
	public String getTip() {
		return tip;
	}

	/**
	 * @param tip the tip to set
	 */
	public void setTip(String tip) {
		this.tip = tip;
	}

	/**
	 * @return the defaultValue
	 */
	@Column(length = 4000)
	public String getDefaultValue() {
		return defaultValue;
	}

	/**
	 * @param defaultValue the defaultValue to set
	 */
	public void setDefaultValue(String defaultValue) {
		this.defaultValue = defaultValue;
	}

	/**
	 * @return the id
	 */
	@Id
	@GeneratedValue(generator = "system-uuid")
	@GenericGenerator(name = "system-uuid", strategy = "uuid")
	@Column(length = 32)
	public String getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @return the form
	 */
	@ManyToOne
	public Form getForm() {
		return form;
	}

	/**
	 * @param form the form to set
	 */
	public void setForm(Form form) {
		this.form = form;
	}

	/**
	 * @return the maxLength
	 */
	public Integer getMaxLength() {
		return maxLength;
	}

	/**
	 * @param maxLength the maxLength to set
	 */
	public void setMaxLength(Integer maxLength) {
		this.maxLength = maxLength;
	}

	/**
	 * @return the minLength
	 */
	public Integer getMinLength() {
		return minLength;
	}

	/**
	 * @param minLength the minLength to set
	 */
	public void setMinLength(Integer minLength) {
		this.minLength = minLength;
	}

	/**
	 * @return the maxValue
	 */
	public Integer getMaxValue() {
		return maxValue;
	}

	/**
	 * @param maxValue the maxValue to set
	 */
	public void setMaxValue(Integer maxValue) {
		this.maxValue = maxValue;
	}

	/**
	 * @return the minValue
	 */
	public Integer getMinValue() {
		return minValue;
	}

	/**
	 * @param minValue the minValue to set
	 */
	public void setMinValue(Integer minValue) {
		this.minValue = minValue;
	}

	/**
	 * @return the mandatory
	 */
	public Boolean getMandatory() {
		return mandatory;
	}

	/**
	 * @param mandatory the mandatory to set
	 */
	public void setMandatory(Boolean mandatory) {
		this.mandatory = mandatory;
	}

	/**
	 * @return the name
	 */
	@Column(length = 255)
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the dataType
	 */
	@Column(length = 100)
	public String getDataType() {
		return dataType;
	}

	/**
	 * @param dataType the dataType to set
	 */
	public void setDataType(String dataType) {
		this.dataType = dataType;
	}

	/**
	 * @return the presentNames
	 */
	@Column(length = 4000)
	public String getPresentNames() {
		return presentNames;
	}

	/**
	 * @param presentNames the presentNames to set
	 */
	public void setPresentNames(String presentNames) {
		this.presentNames = presentNames;
	}

}
